// Ionic Starter App

// angular.module is a global place for creating, registering and retrieving Angular modules
// 'starter' is the name of this angular module example (also set in a <body> attribute in index.html)
// the 2nd parameter is an array of 'requires'
// 'starter.services' is found in services.js
// 'starter.controllers' is found in controllers.js
var starter = angular.module('starter',
        ['ionic','oc.lazyLoad', 'starter.router', 'starter.controllers', 'starter.services'])
        
.run(function ($rootScope,$state,$window,settings,Page,$ionicPlatform,$location,ApiEndpoint,$ionicNavBarDelegate,$ionicBackdrop,sessionStore) {
	$ionicPlatform.ready(function () {
		if (window.cordova && window.cordova.plugins && window.cordova.plugins.Keyboard) {
	      	cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
	    }
	    if (window.StatusBar) {
	        // org.apache.cordova.statusbar required
	        StatusBar.styleDefault();
	    }
	});
	
	$ionicBackdrop.release();
	//$rootScope.$state = $state; // state to be accessed from view
	    
	$rootScope.$on('$stateChangeSuccess',function(event, toState, toParams, fromState, fromParams,$location){
	 	/*if(_hmt){
			_hmt.push(['_trackPageview', window.location.pathname + '#' + toState.url]);	 
		}*/
	});
})

.config(function ($stateProvider, $urlRouterProvider, $httpProvider, $ionicConfigProvider, $ocLazyLoadProvider) {
    $httpProvider.defaults.headers.put['Content-Type'] = 'application/x-www-form-urlencoded';
    $httpProvider.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';
    $httpProvider.interceptors.push('HttpInterceptor');
    
    $ionicConfigProvider.views.swipeBackEnabled(false);
    $ionicConfigProvider.views.transition('none');
    
    $ionicConfigProvider.platform.ios.tabs.style('standard'); 
    $ionicConfigProvider.platform.ios.tabs.position('bottom');
    $ionicConfigProvider.platform.android.tabs.style('standard');
    $ionicConfigProvider.platform.android.tabs.position('standard');

    $ionicConfigProvider.platform.ios.navBar.alignTitle('center'); 
    $ionicConfigProvider.platform.android.navBar.alignTitle('center');

    $ionicConfigProvider.platform.ios.backButton.previousTitleText('').icon('ion-ios-arrow-thin-left');
    $ionicConfigProvider.platform.android.backButton.previousTitleText('').icon('ion-android-arrow-back');        

    $ionicConfigProvider.platform.ios.views.transition('ios'); 
    $ionicConfigProvider.platform.android.views.transition('android');
    
    $ocLazyLoadProvider.config({
        // global configs go here
    });
});

